import { CellRenderer } from "../../../../../fl/controls/listClasses/CellRenderer";
import { GTextFormat } from "../../../../common/GTextFormat";
import { FontUtil } from "../../../../common/font/FontUtil";
import { ObjCreate } from "../../common/ObjCreate";
import { Language } from "../../../../../extend/language/Language";
import { PlayerMiniInfo } from "../../../model/PlayerMiniInfo";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { ColorConfig } from "../../../resource/ColorConfig";
import { Cache } from "../../../cache/Cache";
import { EFriendFlag } from "../../../../../Message/Game/EFriendFlag";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { GButton } from "../../../../../com/mui/controls/GButton";
//class CornucopiaCellRender
    
    export  class CornucopiaCellRender extends CellRenderer
    {
        constructor()
        {
            super();
            this.mouseChildren = true;
            this.mouseEnabled = true;
            this.initStyles();
            this.create();
            return;
        }

        /* internal  */initStyles(): void
        {
            this.setStyle("downSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("overSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("upSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("selectedDownSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("selectedOverSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("selectedUpSkin", new Object /* flash.display.Bitmap */());
            return;
        }

        /* internal  */create(): void
        {
            var loc1=new GTextFormat(FontUtil.songtiName, 12, 11661311);
            loc1.leading = 5;
            this._tfTips = ObjCreate.createTextField("", 0, 0, 185, 36, this, loc1);
            this._tfTips.wordWrap = true;
            this._tfTips.multiline = true;
            this._tfTips.mouseEnabled = false;
            this._btnBless = ObjCreate.createGButton(Language.getString(40302), 200, 4, 70, 26, this, "ButtonLarge");
            this._btnChat = ObjCreate.createGButton(Language.getString(40303), 280, 4, 70, 26, this, "ButtonLarge");
            this._btnBless.enabled = true;
            this._btnChat.enabled = true;
            this._btnBless.drawNow();
            this._btnChat.drawNow();
            ObjCreate.createBg(0, 36, 356, 2, this, "SplitLine");
            this._btnBless.addEventListener(flash.events.MouseEvent.CLICK, this.onBless);
            this._btnChat.addEventListener(flash.events.MouseEvent.CLICK, this.onChat);
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            var loc1=null;
            super.data = arg1;
            if (typeof arg1 === "playerminiinfo") 
            {
                this._playerInfo = arg1 as PlayerMiniInfo;
                this._tfTips.htmlText = HTMLUtil.addColor(this._playerInfo.playerName, ColorConfig.instance.getCampColor(this._playerInfo.camp).color) + HTMLUtil.addColor(Language.getString(40304), "#B1efff");
                if (Cache.instance.friend.isFriend(this._playerInfo.playerName)) 
                {
                    loc1 = Cache.instance.friend.getFriendInfoByPlayerName(this._playerInfo.playerName, EFriendFlag._EFriendFlagFriend);
                    if (loc1.isCornucopiaed()) 
                    {
                        this._btnBless.enabled = false;
                        this._btnBless.drawNow();
                    }
                    else 
                    {
                        this._btnBless.enabled = true;
                        this._btnBless.drawNow();
                    }
                }
                this.drawNow();
            }
            return;
        }

        /* internal  */onBless(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.CornucopiaBlessToFriend, this._playerInfo.playerId));
            this._btnBless.enabled = false;
            this._btnBless.drawNow();
            return;
        }

        /* internal  */onChat(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.ChatPrivate, this._playerInfo));
            return;
        }

        public /* override */ set label(arg1: string)
        {
            return;
        }

        /* internal */ /* var */_tfTips: Object /* flash.text.TextField */;

        /* internal */ /* var */_btnBless: GButton;

        /* internal */ /* var */_btnChat: GButton;

        /* internal */ /* var */_playerInfo: PlayerMiniInfo;
    }
